#ifndef EMPLOYEE_INFO_H
#define EMPLOYEE_INFO_H

#include <QStandardItemModel>
#include <QWidget>

#include "user_info_base_item.h"
#include "dbio/db_manager.h"
#include "define.h"
namespace Ui {
class EmployeeInfo;
}

class EmployeeInfo : public QWidget
{
    Q_OBJECT

public:
    explicit EmployeeInfo(QWidget *parent = nullptr);
    ~EmployeeInfo();
    void initDeptInfo();
    void initUserInfo(QString deptid);
    void buildTree();
private slots:
    void itemClicked(QModelIndex index);
    void expandedSlot(const QModelIndex &index);
private:
    void clearUserItem();
    void updateUser(QList<QList<QString>> userList);
private:
    Ui::EmployeeInfo *ui;
    QStandardItemModel *model;

    // data
    QList<DeptNode> depts;
    QList<UserInfo> users;
    QMap<int,QStandardItem *> deptidForItem;
    QMap<QStandardItem *,int> itemFordeptid;
    QMap<int, QString> deptidForDeptName;
};

#endif // EMPLOYEE_INFO_H
